GBML manual / Screen

green_swap

Turns the screen’s green swap on or off: every pair of side-by-side pixels trades their green, which gives the picture a grainy, interlaced shimmer.

Game Boy: not available

Game Boy Color: not available

Sega Genesis: not available

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

green_swap(on)

Arguments

NameType
onbool

Returns

Nothing.

Description

Turns green swap on or off for the whole screen. With it on, every two pixels that sit side by side trade their green. The left pixel gets the right pixel's green and the right one gets the left's. Red and blue stay where they are.

Where the two greens are different, you get a grainy, shimmering picture, a bit like a bad old TV, a glitch or a fever dream. It suits a haunted room, being poisoned, or a screen that is breaking up. No other effect looks like it.

A real capture, two pictures - the words GREEN SWAP in white letters with a black shadow on a dark blue screen, first with green swap off (clean edges), then with it on (the edges of every letter gain thin green and magenta fringes)A real capture, two pictures - the words GREEN SWAP in white letters with a black shadow on a dark blue screen, first with green swap off (clean edges), then with it on (the edges of every letter gain thin green and magenta fringes)
A real capture, two pictures - the words GREEN SWAP in white letters with a black shadow on a dark blue screen, first with green swap off (clean edges), then with it on (the edges of every letter gain thin green and magenta fringes)

The same words with green swap off, then on. Where white meets dark, the two pixels that swap have very different greens, so each edge gets a thin colored fringe. Real pictures from the mGBA emulator.

A real capture zoomed in 3x, two pictures of the same striped lighthouse - with green swap off its red and white stripes are crisp, with green swap on every edge shimmers with green and magenta grainA real capture zoomed in 3x, two pictures of the same striped lighthouse - with green swap off its red and white stripes are crisp, with green swap on every edge shimmers with green and magenta grain
A real capture zoomed in 3x, two pictures of the same striped lighthouse - with green swap off its red and white stripes are crisp, with green swap on every edge shimmers with green and magenta grain

A closer look, magnified 3 times: the lighthouse from the same two moments. Flat patches of one color do not change at all; the grain lives on the edges.

It costs nothing to run. It is one setting on the screen itself.

What you will and will not see

Swapping two greens that are the same changes nothing, so a big flat patch of one color looks exactly the same with green swap on. The effect shows on edges and patterns: text, outlines of sprites, a checkered floor. A picture made of soft gradients and detail shimmers a lot. A picture made of flat blocks hardly changes.

The pairs are fixed to the screen: pixels 0 and 1 of each row trade, then 2 and 3, and so on. They do not follow sprites. So when something moves one pixel sideways, it starts trading with a different neighbor, and the shimmer on it changes as it moves.

It stays on

Green swap is a setting of the screen, not of any one object or room. Once you turn it on, it stays on through room changes and pauses until you call green_swap(false). Turn it off when the scene that wanted it is over.

On real hardware and in emulators

The setting is a hidden one: Nintendo never wrote it down, but the Game Boy Advance's screen has it, and Gbabel can switch it. The mGBA emulator draws it exactly the way it is described here, pixel for pixel. Other emulators were not checked, so if you plan to show your game in one, try it there first.

The Game Boy Color's screen has nothing like it, so the checker refuses green_swap in a Game Boy Color project.

Example

green_swap(true);

In a Create event, this turns the effect on as soon as the instance exists, and it stays on until something turns it off.

// Hold A to see the shimmer. Let go and the picture goes back to normal.
green_swap(btn_held(BTN_A));

A Step event that tells the screen, every frame, whether A is held. btn_held gives true while A is down and false otherwise, which is exactly what green_swap wants.

On the GBA

One of the screen’s own settings (the register at 0x04000002 - Nintendo never wrote it down), so it costs nothing to run and covers the WHOLE screen: sprites, backgrounds and text alike, and it stays on across rooms until you turn it off. Pixel 0 and pixel 1 trade green, pixel 2 and pixel 3 trade green, and so on across each row; red and blue stay put. A flat area looks the same either way, because swapping two equal greens changes nothing, so you only see it where neighboring pixels differ in green. The mGBA emulator draws it exactly as described (checked pixel for pixel against the same picture with it off); other emulators were not checked.

See also: btn_held